package cn.zyq.demo.system.enums.core;

import cn.zyq.demo.system.exception.BusinessException;

public enum OrderTypeEnum {
    GM("购买道具订单", 1, "GM"),
    FB("发布任务订单", 2, "FB"),
    ;
    private final String key;
    private final Integer value;
    private final String marker;

    OrderTypeEnum(String key, Integer value, String marker) {
        this.key = key;
        this.value = value;
        this.marker = marker;
    }


    public static String getKeyByValue(Integer value) {
        for (OrderTypeEnum item : OrderTypeEnum.values()) {
            if (item.value.equals(value)) return item.key;
        }
        throw new BusinessException(ResponseCodeEnum.ERROR, "无效的value值");
    }

    public static String getValueByKey(String key) {
        for (OrderTypeEnum item : OrderTypeEnum.values()) {
            if (item.key.equals(key)) return item.getValue().toString();
        }
        throw new BusinessException(ResponseCodeEnum.ERROR, "无效的key值");
    }


    public Integer getValue() {
        return value;
    }

    public String getMarker() {
        return this.marker;
    }

    public String getKey() {
        return this.key;
    }
}
